<?php  defined('SYSPATH') or die('No direct script access.');
/**
 * Created by PhpStorm.
 * User: kang
 * Date: 16/2/23
 * Time: 17:53
 */
class Controller_User extends Controller_Base
{
   /**
    * 用户登录
    */
   public function action_login()
   {
      $param = array(
         'username'  => $this->request->post('username'),
         'passwd'    => md5($this->request->post('passwd'))
      );
      $user = Model::factory("User")->getUser($param);
      !$user && Public_Helper::response(301);

      Session::instance()->delete("roleNode");
      Session::instance()->set("user",$user);
      Public_Helper::response(0);
   }

   /**
    * 获取用户详情
    */
   public function action_info()
   {
      $user = Session::instance()->get('user');
      Public_Helper::response(0,$user);
   }

   /**
    * 退出
    */
   public function action_logout()
   {
      Session::instance()->destroy();
      Public_Helper::response(0);
   }


   public function action_register()
   {

   }

   public function action_update_passwd()
   {

   }

}